/**
 * Created by hps on 17-4-30.
 */
public class SortedList1 {
    private Link1 first;

    public SortedList1(Link1[] linkArr) {
        first = null;
        for (int i = 0; i < linkArr.length; i++) {
            insert(linkArr[i]);
        }
    }

    public void insert(Link1 k) {
        Link1 pre = null;
        Link1 current = first;
        while (current != null && k.dData > current.dData) {
            pre = current;
            current = current.next;
        }

        if (current == first)
            first = k;
        else
            pre.next = k;
        k.next = current;
    }

    public Link1 remove() {
        Link1 temp = first;
        first = first.next;
        return temp;
    }
}
